var webpack = require('webpack');
var htmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var WebpackDevServer = require('webpack-dev-server');
var path=require('path');
module.exports= {
    devtool: 'eval-source-map', //生成Source Maps,这里选择eval-source-map
    entry: { page1: "./src/app.js",
             page2: ["./src/b.js", "./src/c.js"],


    },
    devServer: {
        inline: true,
        port: 8099
    },
    output: { //输出目录
        path: __dirname + "/public", //打包后的js文件存放的地方
        filename: '[name]-[hash].js', //打包后的js文件名
    },
    module: {
        loaders: [{
            test: /\.js$/,
            exclude:path.resolve(__dirname, "node_modules"),//屏蔽不需要处理的文件（文件夹）（可选）
            loader: 'babel-loader'
        },{
            test: /\.json$/,
            loader: 'json-loader'
        }, {
            test: /\.css$/,
            use: ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: "css-loader"
            })
        }, {
            test: /\.less$/,
            loader: 'style-loader!css-loader!less-loader'
        }, {
            test: /\.(png|jpg)$/,
            loader: 'url-loader?limit=25000'
        },{
            test:/\.html$/,
            loader: 'html-loader'
        },]
    },

    plugins:[
        new webpack.HotModuleReplacementPlugin(),
        new ExtractTextPlugin("[name]-[hash].css"),
        new htmlWebpackPlugin({
            filename: __dirname + "/public/index.html",
            template:"index.html",
            inject:'body',
            title:'webpack is good',
            chunks: ['page2']
        }),
    ]
}